<template>
  <div class="btn-line">
    <el-button @click="oepnDialog" size="small">反馈问题</el-button>
    <el-dialog
      title="问题反馈"
      :visible.sync="dialogVisible"
      width="800px"
      :before-close="handleClose"
    >
      <div>
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item label="问题名称">
            <el-input
              v-model="form.title"
              size="small"
              style="width: 600px; margin-right: 10px"
              placeholder="请输入内容"
            ></el-input>
          </el-form-item>
          <el-form-item label="详细描述">
            <el-input
              v-model="form.content"
              type="textarea"
              size="small"
              style="width: 600px; margin-right: 10px"
              placeholder="请输入内容"
            ></el-input>
          </el-form-item>
        </el-form>
        <el-button type="primary" size="small" @click="findLinkFile"> 提交 </el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getData, postData } from '@/service/getData';
export default {
  data() {
    return {
      dialogVisible: false,
      loading: false,
      // 表单数据
      form: {
        title: '',
        content: '',
      },
      partition_namesList: [], // 检索范围列表
    };
  },

  mounted() {
    // this.calcData(); // 计算数据
  },
  methods: {
    oepnDialog() {
      this.dialogVisible = true;
      this.form.title = ''; // 清空表单数据
      this.form.content = ''; // 清空表单数据
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done();
        })
        .catch((_) => {});
    },
    findLinkFile() {
      if (!this.form.title) {
        this.$message({
          message: '请输入问题名称',
          type: 'warning',
        });
        return;
      }
      if (!this.form.content) {
        this.$message({
          message: '请输入详细描述',
          type: 'warning',
        });
        return;
      }
      this.loading = true;
      this.queryList = []; // 清空查询结果列表
      // 查询相关文件
      postData(
        '/api/sysmanage/feedback/create_feedback',
        {
          ...this.form,
        },
        'post',
      )
        .then(() => {
          this.$message({
            message: '反馈成功',
            type: 'success',
          });
          this.dialogVisible = false;
        })
        .finally((err) => {});
    },
  },
};
</script>
<style scoped>
.el-dialog__close {
  color: #666;
}
.btn-line {
  display: inline-block;
  width: 80px;
  margin-left: 10px;
}
</style>
